import {
  getLevelFirstJson,
  getLevelZeroJson,
  getSelectDataMapList,
  getTenantID,
} from '@/utils';
import { AnnounceManageAPI } from '../common/type';

/** 定义公告搜索字段信息 */
const getSearchColumns = (
  loadMdicMap: Record<string, any>,
  switchObj: Record<string, any>,
): AnnounceManageAPI.IHeaderSearchType => {
  /** 公告类型 */
  let typeSelect = getSelectDataMapList(
    loadMdicMap?.data?.obj?.[`${getTenantID()}1201`],
    'name',
    'id',
  );

  /** 公告状态 */
  let stateSelect = getSelectDataMapList(
    loadMdicMap?.data?.obj?.[`${getTenantID()}1202`],
    'name',
    'id',
  );

  /** 作废类别 */
  let cancelSelect = getSelectDataMapList(
    loadMdicMap?.data?.obj?.[`${getTenantID()}1203`],
    'name',
    'id',
  );

  let orgDeptList: any[] = [];
  if (switchObj?.queryType == 0) {
    orgDeptList = getLevelZeroJson();
  } else if (switchObj?.queryType == 1) {
    orgDeptList = getLevelFirstJson();
  }

  return [
    {
      name: 'announceTitle',
      label: '公告标题',
      placeholder: '公告标题',
      componentType: 'Input',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'announceContent',
      label: '公告内容',
      placeholder: '公告内容',
      componentType: 'Input',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'state',
      placeholder: '公告状态',
      label: '公告状态',
      componentType: 'Select',
      dataSource: stateSelect,
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'announceType',
      placeholder: '公告类型',
      label: '公告类型',
      componentType: 'Select',
      dataSource: typeSelect,
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'isTop',
      placeholder: '是否置顶',
      label: '是否置顶',
      componentType: 'Select',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
      dataSource: [
        {
          value: 0,
          name: '否',
        },
        {
          value: 1,
          name: '是',
        },
      ],
    },
    {
      name: 'cancelType',
      placeholder: '作废类型',
      label: '作废类型',
      componentType: 'Select',
      dataSource: cancelSelect,
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'createTime',
      placeholder: '编撰',
      label: '编撰时间',
      componentType: 'RangePicker',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: true,
    },
    {
      name: 'signTime',
      placeholder: '签发',
      label: '签发时间',
      componentType: 'RangePicker',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: true,
    },
    {
      name: 'signFormName',
      placeholder: '签发',
      label: '签发',
      componentType: 'DeptAndUser',
      dataSource: orgDeptList,
      allowClear: true,
      md: 6,
      sm: 24,
      whetherSenior: true,
      formOrgType: {
        COMP: 'signCompanyID',
        DEPT: 'signDepartmentID',
        POS: 'signPositionID',
        USER: 'signerID',
      }, //获取组织机构表单name, componentType: 'DeptAndUser', 必传
    },
    {
      name: 'cancelReason',
      label: '作废原因',
      placeholder: '作废原因',
      componentType: 'Input',
      allowClear: true,
      md: 6,
      sm: 24,
      whetherSenior: true,
    },
    {
      name: 'cancelTime',
      placeholder: '作废',
      label: '作废时间',
      componentType: 'RangePicker',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: true,
    },
    {
      name: 'cancelerFormName',
      placeholder: '作废',
      label: '作废',
      componentType: 'DeptAndUser',
      dataSource: orgDeptList,
      allowClear: true,
      md: 6,
      sm: 24,
      whetherSenior: true,
      formOrgType: {
        COMP: 'cancelCompanyID',
        DEPT: 'cancelDepartmentID',
        POS: 'cancelPositionID',
        USER: 'cancelerID',
      }, //获取组织机构表单name, componentType: 'DeptAndUser', 必传
    },
  ];
};
export { getSearchColumns };
